package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: syyyy
 * Date: 2025-07-07
 * Time: 16:20
 */
public class Student implements Cloneable{
    public String name;
    public int age;
    Book book=new Book();
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Student s=(Student)super.clone();
        s.book=(Book)this.book.clone();//这个this表示原本的那个new Student(),s.book表示被拷贝的new Student()
        return s;
    }


}



